import * as actionTypes from "./constants";

interface ActionTypes {
  type: string;
  payload?: any;
}

const initialState = {
  userInfo: {}, //用户信息
  token: "",
};

function reducer(state = initialState, action: ActionTypes) {
  switch (action.type) {
    case actionTypes.SET_USER:
      return { ...state, userInfo: action.payload };
    case actionTypes.SET_TOKEN:
      return { ...state, token: action.payload };
    default:
      return state;
  }
}

export default reducer;
